package cn.wolfcode.enums;

import lombok.Getter;

@Getter
public enum BusinessReportEnum {


    /*枚举需要用的是,隔开*/
    CONSUME("门店","b.name"),
    YEAR("年","DATE_FORMAT(c.create_time,'%Y')"),
    MONTH("月","DATE_FORMAT(c.create_time,'%Y-%m')"),
    DAY("日","DATE_FORMAT(c.create_time,'%Y-%m-%d')");

    private String name;
    private String value;

    //枚举类的构造器本来就是私有的
    private BusinessReportEnum(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public static String findName(Integer value) {
        //获取所有的枚举常量，然后遍历并返回它的name
        BusinessReportEnum[] values = BusinessReportEnum.values();
        //所有的枚举常量
        for (BusinessReportEnum BusinessReportEnum : values) {
            //判断如果传入的枚举常量值等于某一个枚举常量值，则将其名字返回
            if (BusinessReportEnum.getValue().equals(value)) {
                return BusinessReportEnum.getName();
            }
        }
        return null;
    }
}
